# 导包
import requests
import config


# 创建类
class StaffAPI:
    # 员工添加
    def add_staff(self, add_data, token):
        url = config.BASE_URL + "/api/sys/user"
        # add_data = {
        #     "username": "jack0709t2",
        #     "mobile": "13298541101",
        #     "timeOfEntry": "2020-07-09",
        #     "formOfEmployment":1,
        #     "workNumber": "10086",
        #     "departmentName": "销售",
        #     "departmentId": "1266699057968001024",
        #     "correctionTime": "2020-07-30T16:00:00.000Z"
        # }
        header_data = {
            "Authorization": token
        }
        response = requests.post(url=url, json=add_data, headers=header_data)
        return response

    # 修改员工
    def update_user(self, user_id, update_data, token):
        url = config.BASE_URL + "/api/sys/user/{}".format(user_id)
        header_data = {
            "Authorization": token
        }
        response = requests.put(url=url, json=update_data, headers=header_data)
        return response

    # 查询员工
    def select_user(self, user_id, token):
        url = config.BASE_URL + "/api/sys/user/{}".format(user_id)
        header_data = {
            "Authorization": token
        }
        response = requests.get(url=url, headers=header_data)
        return response

    # 删除员工
    def delete_user(self, user_id, token):
        url = config.BASE_URL + "/api/sys/user/{}".format(user_id)
        header_data = {
            "Authorization": token
        }
        response = requests.delete(url=url, headers=header_data)
        return response



if __name__ == '__main__':
    print(StaffAPI().add_staff().json())